{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e9372295-9086-42a4-b5e6-8b944b23396c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n",
      "Requirement already satisfied: statsmodels in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (0.13.0)\n",
      "Requirement already satisfied: patsy>=0.5.2 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from statsmodels) (0.5.2)\n",
      "Requirement already satisfied: pandas>=0.25 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from statsmodels) (1.3.3)\n",
      "Requirement already satisfied: scipy>=1.3 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from statsmodels) (1.7.1)\n",
      "Requirement already satisfied: numpy>=1.17 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from statsmodels) (1.21.2)\n",
      "Requirement already satisfied: pytz>=2017.3 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from pandas>=0.25->statsmodels) (2021.3)\n",
      "Requirement already satisfied: python-dateutil>=2.7.3 in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from pandas>=0.25->statsmodels) (2.8.2)\n",
      "Requirement already satisfied: six in /Users/td/.local/miniconda3/envs/py37_ml/lib/python3.7/site-packages (from patsy>=0.5.2->statsmodels) (1.16.0)\n"
     ]
    }
   ],
   "source": [
    "!pip install statsmodels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0fb201ab-6c9b-462c-90ae-da95413193c6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# ARIMA example\n",
    "from statsmodels.tsa.arima.model import ARIMA\n",
    "from random import random\n",
    "# contrived dataset\n",
    "data = [random() for x in range(1, 10)]\n",
    "# fit model\n",
    "model = ARIMA(data, order=(1, 1, 1))\n",
    "model_fit = model.fit()\n",
    "# make prediction\n",
    "yhat = model_fit.predict(1, len(data), typ='levels')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1867fd7c-a1eb-4932-9929-bf77e2f63921",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.45744451878006176,\n",
       " 0.05745447436218998,\n",
       " 0.5689559785712577,\n",
       " 0.42511518699889417,\n",
       " 0.8304240616914531,\n",
       " 0.6569688015187485,\n",
       " 0.6765906152122402,\n",
       " 0.8022568943913926,\n",
       " 0.8696174167360187]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "76578c1c-2dc2-4af6-b923-7457990432d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.45744449, 0.35043992, 0.18851528, 0.62893341, 0.54160437,\n",
       "       0.84717414, 0.60301082, 0.75792479, 0.84747078])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yhat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "132ebb56-07f1-42f0-a45d-7a892088a334",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
